﻿import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Manager 1.0

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Item {
        id: mainWindow
        anchors.fill: parent

        Text {
            id: header
            anchors.horizontalCenter: mainWindow.horizontalCenter
            anchors.top: mainWindow.top
            anchors.topMargin: 10
            font.bold: true
            text: qsTr("Qt Thread Test")
            MouseArea {
                anchors.fill: parent
                onClicked: Controller.runTask()
            }
        }

        Connections {
            target: Controller
            onProducerLog: {
                producerBox.appendTxt(msg)
            }
            onCustomerLog: {
                customerBox.appendTxt(msg)
            }
        }

        GridLayout {
            anchors.fill: mainWindow
            anchors.topMargin: 30
            columns: 2

            Text {
                Layout.alignment: Qt.AlignHCenter
                text: qsTr("Producer")
            }

            Text {
                Layout.alignment: Qt.AlignHCenter
                text: qsTr("Customer")
            }

            TextBox {
                id: producerBox
                Layout.fillWidth: true
                Layout.fillHeight: true
            }

            TextBox {
                id: customerBox
                Layout.fillWidth: true
                Layout.fillHeight: true
            }
        }
    }
}
